//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.Jpanel;

import com.tool.btn.ChatTypeBtn;
import com.tool.btn.FormsOnOffBtn;
import com.tool.tcpimg.ChatBox;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.LayoutManager;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.image.ImageObserver;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
//聊天记录

public class ChatHistoryJpanel extends JPanel {
	private String[][] typeNames = new String[][] { { "当前", "世界", "队伍", "帮派", "战斗", "系统", "信息" }, { "传音" } };
	private ChatTypeBtn[] chatTypeBtns1;
	private ChatTypeBtn[] chatTypeBtns2;
	private ChatBox[] chatBoxes;
	private int currentType;
	private ImageIcon icon;
	private int chatX;
	private int chatY;
	private int chatW;
	private int chatH;

	public ChatHistoryJpanel() {
		if ("水墨UI".equals(MyIsif.getStyle())) {
		FormsOnOffBtn offBtn;
		int i;
		this.setPreferredSize(new Dimension(550, 520));
		this.setLayout((LayoutManager) null);
		this.setBackground(new Color(0, 0, 0, 0));
		offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 708);
		offBtn.setBounds(550 - 25, 0, 25, 25);
		this.add(offBtn);
		this.chatTypeBtns1 = new ChatTypeBtn[this.typeNames[0].length];

		for (i = 0; i < this.chatTypeBtns1.length; ++i) {
			this.chatTypeBtns1[i] = new ChatTypeBtn("inkImg/button/L20.png", 1, i, this.typeNames[0][i],
					UIUtils.COLOR_WHITE2, UIUtils.TEXT_FONT1, this);
			this.chatTypeBtns1[i].setBounds(450, 50 + i * 30, 60, 24);
			this.add(this.chatTypeBtns1[i]);
		}

		this.chatTypeBtns2 = new ChatTypeBtn[this.typeNames[1].length];

		for (i = 0; i < this.chatTypeBtns2.length; ++i) {
			this.chatTypeBtns2[i] = new ChatTypeBtn("inkImg/button/L20.png", 1, this.typeNames[0].length + i,
					this.typeNames[1][i], UIUtils.COLOR_WHITE2, UIUtils.TEXT_FONT1, this);
			this.chatTypeBtns2[i].setBounds(450, 50 + i * 30, 40, 24);
			this.add(this.chatTypeBtns2[i]);
		}

		this.chatBoxes = new ChatBox[this.typeNames[0].length + this.typeNames[1].length];

		for (i = 0; i < this.chatBoxes.length; ++i) {
			this.chatBoxes[i] = new ChatBox();
			this.chatBoxes[i].setW(401);
			this.chatBoxes[i].setH(410);
		}
		} else {
			FormsOnOffBtn offBtn;
			int i;
			this.setPreferredSize(new Dimension(550, 520));
			this.setLayout((LayoutManager) null);
			this.setBackground(new Color(0, 0, 0, 0));
			offBtn = new FormsOnOffBtn("inkImg/hongmu/s74.png", 1, 708);
			offBtn.setBounds(550 - 25, 0, 25, 25);
			this.add(offBtn);
			this.chatTypeBtns1 = new ChatTypeBtn[this.typeNames[0].length];

			for (i = 0; i < this.chatTypeBtns1.length; ++i) {
				this.chatTypeBtns1[i] = new ChatTypeBtn("inkImg/hongmu/50x50.png", 1, i, this.typeNames[0][i],
						UIUtils.COLOR_YELLOW, UIUtils.TEXT_FONT1, this);
				this.chatTypeBtns1[i].setBounds(470, 50 + i * 30, 50, 25);
				this.add(this.chatTypeBtns1[i]);
			}

			this.chatTypeBtns2 = new ChatTypeBtn[this.typeNames[1].length];

			for (i = 0; i < this.chatTypeBtns2.length; ++i) {
				this.chatTypeBtns2[i] = new ChatTypeBtn("inkImg/hongmu/50x50.png", 1, this.typeNames[0].length + i,
						this.typeNames[1][i], UIUtils.COLOR_YELLOW, UIUtils.TEXT_FONT1, this);
				this.chatTypeBtns2[i].setBounds(470, 50 + i * 30, 50, 25);
				this.add(this.chatTypeBtns2[i]);
			}

			this.chatBoxes = new ChatBox[this.typeNames[0].length + this.typeNames[1].length];

			for (i = 0; i < this.chatBoxes.length; ++i) {
				this.chatBoxes[i] = new ChatBox();
				this.chatBoxes[i].setW(401);
				this.chatBoxes[i].setH(410);
			}
		}

		addMouseWheelListener(new MouseWheelListener() { // from class: org.come.Jpanel.ChatHistoryJpanel.1
			public void mouseWheelMoved(MouseWheelEvent e) {
				if (e.getWheelRotation() == -1) {
					ChatHistoryJpanel.this.chatBoxes[ChatHistoryJpanel.this.currentType].AddAndSubtract(0);
				} else if (e.getWheelRotation() == 1) {
					ChatHistoryJpanel.this.chatBoxes[ChatHistoryJpanel.this.currentType].AddAndSubtract(1);
				}
			}
		});
		updateType();
	}

	public void addChatHistory(String type, String msg) {
		int index = 0;
		label27: for (int i = 0; i < this.typeNames.length; ++i) {
			for (int j = 0; j < this.typeNames[i].length; ++j) {
				if (this.typeNames[i][j].equals(type)) {
					break label27;
				}

				++index;
			}
		}
		if(this.chatBoxes.length>index){
			this.chatBoxes[index].addtext(msg, 401);
		}
	}

	public void updateType(int type) {
		this.currentType = type;
		this.updateType();
	}

	public void updateType() {
		int i;
//        if("水墨UI".equals(MyIsif.getStyle())) {
		for (i = 0; i < this.chatTypeBtns1.length; ++i) {
			if (this.currentType == i) {
				this.chatTypeBtns1[i].setBounds(485, 60 + i * 30, 50, 25);
			} else {
				this.chatTypeBtns1[i].setBounds(482, 60 + i * 30, 50, 25);
			}
		}

		for (i = 0; i < this.chatTypeBtns2.length; ++i) {
			if (this.currentType == this.typeNames[0].length + i) {
				this.chatTypeBtns2[i].setBounds(485, 450 - (i + 30), 50, 25);
			} else {
				this.chatTypeBtns2[i].setBounds(482, 450 - (i + 30), 50, 25);
			}
		}
//        } else {
//            for(i = 0; i < this.chatTypeBtns1.length; ++i) {
//                if (this.currentType == i) {
//                    this.chatTypeBtns1[i].setBounds(434, 50 + i * 30, 59, 24);
//                } else {
//                    this.chatTypeBtns1[i].setBounds(430, 50 + i * 30, 59, 24);
//                }
//            }
//
//            for(i = 0; i < this.chatTypeBtns2.length; ++i) {
//                if (this.currentType == this.typeNames[0].length + i) {
//                    this.chatTypeBtns2[i].setBounds(434, 450 - (i + 30), 59, 24);
//                } else {
//                    this.chatTypeBtns2[i].setBounds(430, 450 - (i + 30), 59, 24);
//                }
//            }
//        }

		this.updateNew();
	}

	public void updateNew() {
		this.chatBoxes[this.currentType].update();
	}

	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		if("水墨UI".equals(MyIsif.getStyle())) {
		this.icon = new ImageIcon("inkImg/background/ltjl.png");
		g.drawImage(this.icon.getImage(), 0, 0, (ImageObserver) null);
		this.chatX = 43;
		this.chatY = 55;
		this.chatW = 461;
		this.chatH = 430;
        } else {
            this.icon = new ImageIcon("inkImg/hongmu/聊天记录.png");
            g.drawImage(this.icon.getImage(), 0, 0, (ImageObserver)null);
            this.chatX = 25;
            this.chatY = 55;
            this.chatW = 398;
            this.chatH = 388;
        }

		Graphics g2 = g.create(this.chatX, this.chatY, this.chatW, this.chatH);
		this.chatBoxes[this.currentType].paint(g2);
		g2.dispose();
	}

	public ChatBox getChatTypeBtns1() {
		return this.chatBoxes[this.currentType];
	}

	public int getChatX() {
		return this.chatX;
	}

	public void setChatX(int chatX) {
		this.chatX = chatX;
	}

	public int getChatY() {
		return this.chatY;
	}

	public void setChatY(int chatY) {
		this.chatY = chatY;
	}

	public int getChatW() {
		return this.chatW;
	}

	public void setChatW(int chatW) {
		this.chatW = chatW;
	}

	public int getChatH() {
		return this.chatH;
	}

	public void setChatH(int chatH) {
		this.chatH = chatH;
	}
}
